package br.ufc.si.managedBean;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import modelo.Servico;
import dao.ServicoDao;

@ManagedBean
@SessionScoped
public class ServicoBean {
	private ServicoDao dao;
	private Servico servico;
	private List<Servico> list;
	private String tipoServico;
	private String msg;
	
	
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public String getTipoServico() {
		return tipoServico;
	}
	public String mostrarServico(){
		HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
		HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
		
		session.setAttribute("servico", request.getParameter("servico"));
		
		return "/servicos_basicos?faces-redirect=true";
	}

	public void setTipoServico(String tipoServico) {
		this.tipoServico = tipoServico;
		
	}


	
	
	public ServicoDao getDao() {
		return dao;
	}

	public void setDao(ServicoDao dao) {
		this.dao = dao;
	}

	public Servico getServico() {
		return servico;
	}

	public void setServico(Servico servico) {
		this.servico = servico;
	}

	public List<Servico> getList() {
		return list;
	}

	public List<Servico> getListaTipo() {
		return dao.getListaTipo();
	}
	
	public String nomeImagem(){
		HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
		
		
		String nome = (String)session.getAttribute("servico");
	return "/img/servicos/" + nome +".png";
	}
	
	public void setList(List<Servico> list) {
		this.list = list;
	}


	
	public ServicoBean(){
		dao = new ServicoDao();
		servico = new Servico();
		list = new ArrayList<Servico>();
	} 
	
}
